package main

import "fmt"

// 稍微改变练习 11.11，允许 mapFunc() 接收不定数量的 items。

type obj interface{}

func mapFunc(mf func(obj) obj, list ...obj) []obj {
	res := make([]obj, len(list))
	for i, v := range list {
		res[i] = mf(v)
	}
	return res
}

func main() {
	mf := func(o obj) obj {
		switch o.(type) {
		case int:
			return (o.(int) + 1) * o.(int)
		case string:
			return o.(string) + "***" + o.(string)
		case float32:
			return o.(float32) * 1.2
		case float64:
			return o.(float64) * 1.2
		}
		return o
	}

	fmt.Println(mapFunc(mf, 14.44, 15, "string", [1]int{1}))
}
